# 选择镜像
FROM golang:1.19.2 AS stage1
# 拷贝文件
COPY . /ginServe
# 设置工作目录
WORKDIR /ginServe

# 设置代理 打包服务
RUN set -ex \
    && go env -w GO111MODULE=on \
    && go env -w GOPROXY=https://goproxy.cn,direct \
    && go install github.com/swaggo/swag/cmd/swag@latest \
    && swag init \
    && go build -o web-server *.go 

FROM ubuntu
COPY --from=stage1 /ginServe/web-server /server/web-server
WORKDIR /server

# 暴露端口
EXPOSE 8080

# 容器启动时启动服务
ENTRYPOINT ["./web-server"]